package com.lancoo.cvas.schedues;

import cn.hutool.core.util.StrUtil;
import com.lancoo.cvas.pojo.constant.GlobalConstant;
import com.lancoo.cvas.pojo.response.basicPlatform.SubSystemsMainServer;
import com.lancoo.cvas.service.YunService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: liufeng
 * @CreateTime: 2024-01-19  10:28
 * @Description:
 */
@Component
@Slf4j
@EnableAsync(proxyTargetClass = true)
public class InitParam {
    @Resource
    private YunService yunService;

    @Scheduled(cron = "0 0 * * * ?")
    public void initAccessPath() {
        SubSystemsMainServer e31 = yunService.getSubSystemsMainServer("E31",false);
        if (StrUtil.isNotEmpty(e31.getWsSvrAddr())){
            GlobalConstant.ACCESS_PATH = e31.getWsSvrAddr();
        }else {
            log.error("E31 初始化后端访问路径失败，路径为空");
        };
    }
}
